
function addLoadEvent(func){
    var oldonload=window.onload;
    if(typeof window.onload!="function"){
        window.onload=func;
    }else{
        window.onload=function(){
            oldonload();
            func();
        }
    }
}


function gotop(){
    var btn= document.getElementById('gotop');
    var timer = null;
    var isTop = true;
    var clientHeight = document.documentElement.clientHeight;

    window.onscroll = function() {
        var osTop = document.documentElement.scrollTop || document.body.scrollTop;
        if (osTop >= clientHeight) {
            btn.style.display = "block";
        } else {
            btn.style.display = "none";
        };
        if (!isTop) {
            clearInterval(timer);
        };
        isTop = false;

    };
    btn.onclick = function() {
        timer = setInterval(function(){
            var osTop = document.documentElement.scrollTop || document.body.scrollTop;
            var ispeed = Math.floor(-osTop / 7);
            document.documentElement.scrollTop = document.body.scrollTop = osTop+ispeed;
            if (osTop == 0) {
                clearInterval(timer);
            };
            isTop = true;

        },30);
    };
}


function openlink(){
    if(!document.getElementById) return false;
    if(!document.getElementById("layer")) return false;
    if(!document.getElementById("copy_close")) return false;
    var oA=document.getElementById("ling_a");
    var oDiv=document.getElementById("layer");
    var oCloseC=document.getElementById("copy_close");
    oA.onclick=function(){
        oDiv.style.display="block";
    }
    oCloseC.onclick=function(){
        oDiv.style.display="none";
    }
}


function openMa(){
    var btn=document.getElementById("mas");
    var oDiv=document.getElementById("layerma");
    var oClose=document.getElementById("layerblack");
//	var oClose2=document.getElementById("close");
    btn.onclick=function(){
        oDiv.style.display="block";
    }

    oClose.onclick=function(){
        oDiv.style.display="none";
    }
//	oClose2.onclick=function(){
//		oDiv.style.display="none";
//	}
}

function openMatop(){

    //var btn=document.getElementById("matop");
    var oDiv=document.getElementById("layerma");
    var oClose=document.getElementById("layerblack");
    var oClose2=document.getElementById("close");

    /*btn.onclick=function(){

        oDiv.style.display="block";console.log("222");
    }*/

    oClose.onclick=function(){
        oDiv.style.display="none";
    }
    oClose2.onclick=function(){
        oDiv.style.display="none";
    }
}




function closeTips(){
    if(!document.getElementById) return false;
    if(!document.getElementById("layerkong")) return false;
    var oDiv=document.getElementById("layerkong");
    var oLi=document.getElementById("kong_close");
    oLi.onclick=function(){
        oDiv.style.display="none";
        location.href='/';
    }
}



function textLength(){
    var aBefore=document.getElementsByClassName("jia_before");
    var aAfer=document.getElementsByClassName("jia_after");
    var oS=window.screen.width;

    if(oS<360){
        for(var i=0;i<aBefore.length;i++){
            var aBfe=parseFloat(aBefore[i].innerHTML);
            aBefore[i].innerHTML=Math.round(aBfe)+"鍏�";
        }
        for(var e=0;e<aAfer.length;e++){
            var aEm=aAfer[e].getElementsByTagName("em");
            for(var ee=0;ee<aEm.length;ee++){
                var emNum=parseFloat(aEm[ee].innerHTML);
                aEm[ee].innerHTML=Math.round(emNum)+"鍏�";
            }
        }

    }
}

function addClass(element,value){
    if(!element.className){
        element.className=value;
    }else{
        newClassName=element.className;
        newClassName+="";
        newClassName+=value;
        element.className=newClassName;
    }
}

function sex(){
    var oA=document.getElementById("sex");
    var oSpan=oA.getElementsByTagName("span")[0];
    var oUl=document.getElementById("sexul");
    var aA=oUl.getElementsByTagName("a");
    var gou=oUl.getElementsByTagName("img");

    oA.onclick=function(){
        if(oUl.style.display=="none"){
            oUl.style.display="block";
        }else{
            oUl.style.display="none";
        }
    }
    for(var i=0;i<aA.length;i++){
        aA[i].index=i;
        aA[i].onclick=function(){
            oSpan.innerHTML=this.innerHTML;
            oUl.style.display="none";

            for(var i=0;i<aA.length;i++){
                aA[i].className="";
                gou[i].className=""
            }
            addClass(this,"red");
            addClass(gou[this.index],"gou");
        }
    }

}




